package com.swpu.controller;

import com.swpu.exception.BusinessException;
import com.swpu.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException e){
        System.out.println("寄");
        return new Result(e.geteCode(),null,e.getMessage());
    }

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException e){
        System.out.println("寄");
        return new Result(e.geteCode(),null,e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result doException(Exception e){
        System.out.println("寄");
        return new Result(666,null,"哈哈,寄了");
    }
}
